<?php
/*
 * @Author: your name
 * @Date: 2020-11-06 14:39:22
 * @LastEditTime: 2020-11-09 14:34:51
 * @LastEditors: Please set LastEditors
 * @Description: 内网ip控制器
 * @FilePath: /special/application/adminapiv3/controller/asset_manage/address/IntranetIpController.php
 */
namespace app\adminapiv3\controller\asset_manage\address;

use app\adminapiv3\controller\BaseController;
use app\adminapiv3\service\asset_manage\address\IntranetIpService;
use think\Request;


class IntranetIpController extends BaseController
{
    /**
     * @name: 列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-11-06 14:41:19
     */
    public function list (Request $request)
    {
        $input = $request->only([
            'address_id','ip','type'
        ], 'post');

        $this->validate($input, 'IntranetIp.listFilter');

        $IntranetIpService = new IntranetIpService();
        $data = $IntranetIpService->list($input);
        return $this->jsonOutPut($data);
    }

    /**
     * @name: 添加
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-11-06 14:41:53
     */
    public function add (Request $request)
    {
        $input = $request->only([
            'address_id','ip'
        ], 'post');

        $this->validate($input, 'IntranetIp.add');

        $IntranetIpService = new IntranetIpService();
        $IntranetIpService->add($input);
        return $this->jsonOutPut();
    }

    /**
     * @name: 修改
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-11-06 14:42:11
     */
    public function modify(Request $request)
    {
        $input = $request->only([
            'id','address_id','ip'
        ], 'post');

        $this->validate($input, 'IntranetIp.modify');

        $IntranetIpService = new IntranetIpService();
        $IntranetIpService->modify($input);
        return $this->jsonOutPut();
    }

    /**
     * @name: 删除
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-11-06 14:42:26
     */
    public function delete (Request $request)
    {
        $input = $request->only(['id_s'], 'post');

        $this->validate($input, 'IntranetIp.delete');

        $IntranetIpService = new IntranetIpService();
        $IntranetIpService->delete($input['id_s']);
        return $this->jsonOutPut();
    }
}